package com.x.path;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * ClassName: PathController
 * Package: IntelliJ IDEA
 * Description:
 * Written by HanXu
 * Create 2024.09.10 23:49
 */

@Controller
@RequestMapping("path")
@ResponseBody
public class PathController {

    /**
     * 动态路径设计  {key} 等同于 *
     * {key}是在形参列表获取传入的参数
     * 接受路径参数  String username,String password --> 接受param格式参数
     * 所以必须使用 @PathVariable 代表为路径传递参数
     */
    @RequestMapping("{account}/{password}")
    public String login(@PathVariable(value = "account") String username, @PathVariable String password){
        System.out.println("name = " + username + ", password = " + password);
        return "name = " + username + ", password = " + password;
    }
}
